import {axios} from '@/utils/request'

// api接口列表
const api = {
    list: '/file-management/file-descriptor/page',
    rename: '/file-management/file-descriptor',
    delete: '/file-management/file-descriptor',
    move: '/file-management/file-descriptor/move',
    downloadToken: '/file-management/file-descriptor/download/{id}/token',
    download: '/file-management/file-descriptor/download/{id}'
}

// 列表记录
export function list(params) {
    return axios({
        url: api.list,
        method: 'get',
        params
    })
}

/**
 * 编辑记录
 * @param {*} id
 * @param {*} data
 */
export function rename(id, data) {
    return axios({
        url: api.rename.replace('{id}', id),
        method: 'post',
        data
    })
}

/**
 * 删除记录
 * @param {*} data
 */
export function deleted(data) {
    return axios({
        url: api.delete,
        method: 'delete',
        data
    })
}

/**
 * 移动分组
 * @param {*} data
 */
export function move(data) {
    return axios({
        url: api.move,
        method: 'post',
        data: data
    })
}

export function downloadToken(id) {
    return axios({
        url: api.downloadToken.replace('{id}', id),
        method: 'get'
    })
}

export function download(id, params) {
    return axios({
        url: api.download.replace('{id}', id),
        method: 'get',
        params,
        responseType: 'blob'
    })
}

